package vtt.android.dapanhc.utils;

import java.text.ParseException;

import vtt.android.dapanhc.Constants;
import vtt.android.library.utils.VttUtils;
import android.content.SharedPreferences;

public class VttDateUtils {
	/**
	 * @return format day:   yyyyMMdd
	 */
	public static String getCurrentDayString(SharedPreferences pref){
		return pref.getString(Constants.SHARE_KEY_CURRENT_DAY, "19000101");
	}
	
	/**
	 * @return format day:   dd/MM/yyyy
	 */
	public static String getCurrentDayDisplay(SharedPreferences pref){
		String dayDisplay = getCurrentDayString(pref);
		try {
			return VttUtils.formatDate(dayDisplay, "yyyyMMdd", "dd/MM/yyyy");
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	public static String revertYYYYMMDD(String ddMMyyy){
		String[] dateArr = ddMMyyy.split("/");
		return dateArr[2] + dateArr[1] + dateArr[0];
	}
}
